//
//  HZSQLiteHandler.h
//  Expert
//
//  Created by 刘华舟 on 15/4/8.
//  Copyright (c) 2015年 BLUEBLACK. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface HZResultSet : NSObject

@property (nonatomic, assign, readonly) NSUInteger rowCount; // 行数
@property (nonatomic, assign, readonly) NSUInteger columnCount; // 列数
@property (nonatomic, strong, readonly) NSArray *allColumnName;
@property (nonatomic, assign, readonly) BOOL hasNext;

- (instancetype)initWithDataArray:(NSArray *)dataArray columnNameToIndexMap:(NSDictionary *)columnNameToIndexMap;

- (NSInteger)columnIndexForName:(NSString *)columnName;
- (NSString *)columnNameForIndex:(NSInteger)columnIndex;

- (NSInteger)intForColumn:(NSString *)columnName;
- (NSInteger)intForColumnIndex:(NSInteger)columnIndex;

- (long)longForColumn:(NSString *)columnName;
- (long)longForColumnIndex:(NSInteger)columnIndex;

- (long long)longLongIntForColumn:(NSString *)columnName;
- (long long)longLongIntForColumnIndex:(NSInteger)columnIndex;

- (BOOL)boolForColumn:(NSString *)columnName;
- (BOOL)boolForColumnIndex:(NSInteger)columnIndex;

- (double)doubleForColumn:(NSString *)columnName;
- (double)doubleForColumnIndex:(NSInteger)columnIndex;

- (NSString *)stringForColumn:(NSString *)columnName;
- (NSString *)stringForColumnIndex:(NSInteger)columnIndex;

- (NSDate *)dateForColumn:(NSString *)columnName;
- (NSDate *)dateForColumnIndex:(NSInteger)columnIndex;

- (NSData *)dataForColumn:(NSString *)columnName;
- (NSData *)dataForColumnIndex:(NSInteger)columnIndex;

- (id)objectForColumnName:(NSString *)columnName;
- (id)objectForColumnIndex:(NSInteger)columnIndex;

- (BOOL)columnIsNullColumnName:(NSString *)columnName;
- (BOOL)columnIsNullForIndex:(NSInteger)columnIndex;

@end


@interface HZSQLiteHandler : NSObject

@property (nonatomic, copy, readonly) NSString *databaseName;

+ (instancetype)defaultHandler;

- (BOOL)executeUpdate:(NSString *)sql, ... NS_REQUIRES_NIL_TERMINATION; // 必须以nil结尾

- (BOOL)executeUpdate:(NSString *)sql withArguments:(NSArray *)arguments;

- (HZResultSet *)executeQuery:(NSString *)sql, ... NS_REQUIRES_NIL_TERMINATION; // 必须以nil结尾

- (HZResultSet *)executeQuery:(NSString *)sql withArguments:(NSArray *)arguments;

- (BOOL)executeStatements:(NSString *)sql;

@end
